package com.xnyzc.lhy.mis.controller.cmsapi.punishment;


import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.mis.entity.param.account.OaDAccountAdjustmentDetailParam;
import com.xnyzc.lhy.mis.entity.param.punishment.DriverPenaltyTmpResult;
import com.xnyzc.lhy.mis.entity.param.punishment.OaDUserPenaltyParam;
import com.xnyzc.lhy.mis.entity.param.punishment.OaDUserPenaltyQueryParam;
import com.xnyzc.lhy.mis.service.cms.citymanage.CityManageService;
import com.xnyzc.lhy.mis.service.cms.user.SysUserService;
import com.xnyzc.lhy.mis.service.impl.punishment.OaDUserPenaltyServiceImpl;
import com.xnyzc.lhy.mis.service.punishment.IOaDUserPenaltyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 司机处罚表  前端控制器
 * </p>
 *
 * @author cuichaoqun
 * @since 2019-10-27
 */
@RestController
@Api(value="司机处罚",tags={"司机处罚"})
@RequestMapping("/cmsapi/oaDUserPenalty")
public class OaDUserPenaltyController {
    @Autowired
    IOaDUserPenaltyService iOaDUserPenaltyService;
    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private CityManageService cityManageService;

    /**
     * 查询司机是否处罚字典
     * */
    @ApiOperation(value = "查询司机是否处罚字典", notes = "查询司机是否处罚字典")
    @PostMapping(value = "/slectIsPenalty")
    public Rv slectIsPenalty() {
        return iOaDUserPenaltyService.slectIsPenalty();
    }

    /**
     * 添加司机处罚内容
     *
     * */
    @ApiOperation(value = "添加司机处罚信息", notes = "添加司机处罚信息")
    @PostMapping(value = "/insertoaDUserPenalty")
    public Rv insertoaDUserPenalty(@RequestBody List<OaDUserPenaltyParam> oaDUserPenaltyParamList) {
        try{
            return iOaDUserPenaltyService.insertoaDUserPenalty(oaDUserPenaltyParamList);
        }catch (PangException ex){
            return Rv.error(ex.getErrorCode());
        }
    }

    /**
     * 查询司机处罚列表
     *
     * */
    @ApiOperation(value = "查询司机处罚列表", notes = "查询司机处罚列表")
    @PostMapping(value = "/queryDriverPenaltyList")
    public Rv queryDriverPenaltyList(@RequestBody OaDUserPenaltyQueryParam oaDUserPenaltyQueryParam) {

        return iOaDUserPenaltyService.queryDriverPenaltyList(oaDUserPenaltyQueryParam);
    }

    /**
     * 获取司机处罚列表所有城市
     *
     * @return
    */
    @ApiOperation(value = "获取司机处罚列表所有城市", notes = "获取司机处罚列表所有城市")
    @GetMapping(value = "/getAllCity")
    public Rv getAllCity() {
        return cityManageService.getAllCity();
    }

    /**
     * 获取司机处罚模板和司机违规模板文件id
     *
     * @return
     */
    @ApiOperation(value = "获取司机处罚模板和司机违规模板文件id", notes = "获取司机处罚模板和司机违规模板文件id")
    @GetMapping(value = "/getDriverPenaltyTmpId")
    public Rv getDriverPenaltyTmpId() {
        DriverPenaltyTmpResult driverPenaltyTmpResult = iOaDUserPenaltyService.getDriverPenaltyTmpId();

        return Rv.wrap(EErrorCode.success, driverPenaltyTmpResult);
    }
}
